﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OfficeOpenXml;

namespace CIS470MetricsTracking
{
	public partial class ProjectManagement : Form
	{
		private ProjectSelection proj_sel;
		private Dictionary<string, User> users;
		private ArrayList metrics;
		private ArrayList cias;
		private ArrayList lis;
		private ArrayList mcategories;
		private ArrayList reports;
		private ArrayList csdates;
		Project selected_project;

		private string series1_name = "Series1";
		private string series2_name = "Series2";
		private string series3_name = "Series3";
		private string series4_name = "Series4";
		private string series5_name = "Series5";
		private string series6_name = "Series6";
		private string series7_name = "Series7";
		private string series8_name = "Series8";

		public ProjectManagement(ProjectSelection proj_sel, Project selected_project)
		{
			InitializeComponent();

			this.proj_sel = proj_sel;
			this.selected_project = selected_project;
		}

		private void ProjectManagement_Load(object sender, EventArgs e)
		{
			users = new Dictionary<string, User>();
			metrics = new ArrayList();
			cias = new ArrayList();
			lis = new ArrayList();
			mcategories = new ArrayList();
			reports = new ArrayList();


			if (ControllerManager.user_controller.getUserAccessLevel() != 1) {
				foreach (Control c in tabPage1.Controls) {
					c.Enabled = false;
				}
				foreach (Control c in tabPage4.Controls) {
					c.Enabled = false;
				}
			} else {
				foreach (Control c in tabPage1.Controls) {
					c.Enabled = true;
				}
				foreach (Control c in tabPage4.Controls) {
					c.Enabled = true;
				}
			}

			string query = "select * from dboUser";
			DataSet ds = new DataSet();
			DataTable dt = new DataTable();

			ds = ControllerManager.data_controller.executeSelectQuery(query);

			if (ds != null) {
				dt = ds.Tables[0];

				foreach (DataRow row in dt.Rows) {
					User user = new User(row.ItemArray[1].ToString(), row.ItemArray[2].ToString(), row.ItemArray[3].ToString(),
						row.ItemArray[7].ToString(), row.ItemArray[5].ToString(), (int)row.ItemArray[8],
						row.ItemArray[4].ToString(), (int)row.ItemArray[0]);
					users.Add(user.getEmail(), user);
				}

				if (users.Count != 0) {
					foreach (var k in users.Keys) {
						cbxSelectUser.Items.Add(k.ToString());
					}
				}
			}

			query = "select actualMetric from dboMetricReference";
			ds = ControllerManager.data_controller.executeSelectQuery(query);

			if (ds != null) {
				dt = ds.Tables[0];

				foreach (DataRow row in dt.Rows) {
					metrics.Add(row.ItemArray[0].ToString());
				}

				if (metrics.Count != 0) {
					foreach (var m in metrics) {
						cbxMetricSelect.Items.Add(m);
					}
				}
			}

			query = "select category from dboCIA";
			ds = ControllerManager.data_controller.executeSelectQuery(query);

			if (ds != null) {
				dt = ds.Tables[0];

				foreach (DataRow row in dt.Rows) {
					cias.Add(row.ItemArray[0].ToString());
				}

				if (cias.Count != 0) {
					foreach (var c in cias) {
						cbxCIASelector.Items.Add(c);
					}
				}
			}

			

			query = "select distinct indicatorName from Q_ProjectReportedResults";
			ds = ControllerManager.data_controller.executeSelectQuery(query);

			if (ds != null) {
				dt = ds.Tables[0];

				foreach (DataRow row in dt.Rows) {
					reports.Add(row.ItemArray[0].ToString());
				}

				if (reports.Count != 0) {
					foreach (var r in reports) {
						cbxReportSelector.Items.Add(r);
					}
				}
			}

			this.Text = this.Text + " <Project Name: " + selected_project.getProjectName() + ", Report Period: " +
				ControllerManager.project_controller.calculate_report_period(selected_project.getProjectStart()) + ">";

			cbxCSDate.Visible = false;
			lblCSDate.Visible = false;
			ChartRefresh();
		}

		private void cbxSelectUser_SelectedValueChanged(object sender, EventArgs e)
		{
			User user = users[cbxSelectUser.SelectedItem.ToString()];

			if (user.getAccessLevel() == 1) {
				rbtnPM.Select();
			} else {
				rbtnUser.Select();
			}

			txtFirstName.Text = user.getFirstName();
			txtLastName.Text = user.getLastName();
			txtEmail.Text = user.getEmail();
			txtPassword.Text = user.getPassword();

			btnUpdate.Enabled = false;
		}

		private void ProjectManagement_FormClosing(object sender, FormClosingEventArgs e)
		{
			proj_sel.Show();
			proj_sel.BringToFront();
		}

		private void btnUpdate_Click(object sender, EventArgs e)
		{
			if (cbxSelectUser.SelectedIndex >= 0) {
				User user = users[cbxSelectUser.SelectedItem.ToString()];
				if (rbtnPM.Checked) {
					user.setAccessLevel(1);
				} else {
					user.setAccessLevel(2);
				}

				user.setFirstName(txtFirstName.Text.Trim());
				user.setLastName(txtLastName.Text.Trim());
				user.setEmail(txtEmail.Text.Trim());
				user.setPassword(txtPassword.Text.Trim());

				if (ControllerManager.user_controller.getUserEmail().Equals(user.getEmail())) {
					MessageBox.Show("You can not update your own user information.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
					return;
				} else {
					if (!ControllerManager.user_controller.update_user(user, user.getUserId())) {
						MessageBox.Show("Was not able to update user.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					} else {
						MessageBox.Show("User was updated in the system.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
					}
				}

			} else {
				MessageBox.Show("Must first select a user to update.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}

		private void cbxMetricSelect_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (gvDataEntry.Columns.Count != 0) {
				gvDataEntry.Columns.Clear();
			}

			ArrayList parameters = ControllerManager.metrics_controller.getParams(cbxMetricSelect.SelectedItem.ToString());
			foreach (var param in parameters) {
				if (param.ToString().Equals("none")) {
					gvDataEntry.Columns.Add("Result", "Result");
				} else {
					gvDataEntry.Columns.Add(param.ToString(), param.ToString());
				}
			}
			gvDataEntry.Rows.Add();
		}

		private void btnAdd_Click(object sender, EventArgs e)
		{
			if (rbtnManualEntry.Checked) {
				if (validate_manual_input()) {
					if (rbtnBaseLine.Checked) {
						manual_entry(true);
					} else {
						manual_entry(false);
					}
				} else {
					return;
				}
			} else {
				if (validate_input_file(txtFilePath.Text)) {
					excel_entry(txtFilePath.Text);
				}
			}
		}

		private void manual_entry(bool is_baseline)
		{
			bool success = false;
			string query = "";

			DialogResult result = MessageBox.Show("Are you sure you want to commit this data?\n" +
					"You will not be able to change this data once commited.", "Warning", MessageBoxButtons.OKCancel,
					MessageBoxIcon.Warning);

			if (result == DialogResult.OK) {
				foreach (DataGridViewCell item in gvDataEntry.Rows[0].Cells) {
					int metricId;
					int mpId;
					int linkId;
					if (item.OwningColumn.HeaderText.Equals("Result")) {
						linkId = ControllerManager.metrics_controller.getLinkId(cbxMetricSelect.SelectedItem.ToString(),
							"none", out metricId, out mpId);
					} else {
						linkId = ControllerManager.metrics_controller.getLinkId(cbxMetricSelect.SelectedItem.ToString(),
							item.OwningColumn.HeaderText, out metricId, out mpId);
					}

					if (is_baseline) {
						query = "insert into dboprojectBaselines (projectId, linkId, baselineDate, baseline) " +
							"values (" + ControllerManager.project_controller.getProjectId(selected_project.getProjectName()) +
							", " + linkId + ", '" + DateTime.Now.ToShortDateString() + "', " + Int32.Parse(item.Value.ToString()) +
							")";
					} else {
						query = "insert into dboProjectActualResults (projectId, linkId, reportDate, actualResult) " +
							"values (" + ControllerManager.project_controller.getProjectId(selected_project.getProjectName()) +
							", " + linkId + ", '" + DateTime.Now.ToShortDateString() + "', " + Int32.Parse(item.Value.ToString()) +
							")";
					}

					success = ControllerManager.data_controller.executeQuery(query);
					if (!success) {
						break;
					}
				}
			} else {
				return;
			}

			if (success) {
				MessageBox.Show("Data entered successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
			} else {
				MessageBox.Show("There was a error saving the data please validate input.\n" +
					"Potential Reasons:\n" +
					"1. Current selected metric may already be present for this report period.\n" +
					"2. Current selected metric may already have a baseline present.", "Error", MessageBoxButtons.OK,
					MessageBoxIcon.Error);
			}
		}

		private bool validate_manual_input()
		{
			if (cbxMetricSelect.SelectedItem == null) {
				MessageBox.Show("You must first select a metric to add data.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return false;
			}

			foreach (DataGridViewCell item in gvDataEntry.Rows[0].Cells) {
				if (item.Value == null) {
					MessageBox.Show("Parameters can not be left empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					return false;
				} else {
					int temp;
					if (!Int32.TryParse(item.Value.ToString(), out temp)) {
						MessageBox.Show("Parameters must be a numerical value.", "Error", MessageBoxButtons.OK,
							MessageBoxIcon.Error);
						return false;
					}
				}
			}
			return true;
		}

		private void cbxReportSelector_SelectedIndexChanged(object sender, EventArgs e)
		{
			DataTable report;
			DataTable details;
			btnPrintReport.Enabled = true;

			if (gvReports.Columns.Count != 0) {
				gvReports.Columns.Clear();
			}

			if (cbxReportSelector.Text == null || cbxReportSelector.Text == "") {
				MessageBox.Show("You must select a valid report first.");
			} else {
				if (chbxBaseline.Checked == false) {
					report = ControllerManager.report_controller.getReportResults(this.selected_project.getProjectName(), cbxReportSelector.SelectedItem.ToString());
				} else {
					report = ControllerManager.report_controller.getReportBaselines(this.selected_project.getProjectName(), cbxReportSelector.SelectedItem.ToString());
				}

                details = ControllerManager.report_controller.getReportDetails(this.selected_project.getProjectName(), cbxReportSelector.SelectedItem.ToString());

				gvReports.DataSource = report;
			}
		}

		private void btnBrowse_Click(object sender, EventArgs e)
		{
			ofdSelectFile.Filter = "Excel Files (*.xlsx)|*.xlsx";
			ofdSelectFile.FilterIndex = 0;
			DialogResult result = ofdSelectFile.ShowDialog();

			if (result == DialogResult.OK) {
				txtFilePath.Text = ofdSelectFile.FileName;
			}
		}

		private void rbtnManualEntry_CheckedChanged(object sender, EventArgs e)
		{
			btnBrowse.Enabled = false;
			txtFilePath.Enabled = false;
			cbxMetricSelect.Enabled = true;
			gvDataEntry.Enabled = true;
			gbManualSelect.Enabled = true;
		}

		private void rbtnLoadExcel_CheckedChanged(object sender, EventArgs e)
		{
			cbxMetricSelect.Enabled = false;
			gvDataEntry.Enabled = false;
			gbManualSelect.Enabled = false;
			btnBrowse.Enabled = true;
			txtFilePath.Enabled = true;
		}

		private void excel_entry(string path)
		{
			FileInfo file = new FileInfo(path);
			ExcelPackage excelPackage = new ExcelPackage(file);
			var workbook = excelPackage.Workbook;
			var worksheet = workbook.Worksheets[1];

			if (worksheet.Name.Equals("excelGhanttView")) {
				string start_query = "insert into ";
				start_query += worksheet.Name + " (importDate, projectId, reportperiod, ";

				for (int i = 1; i <= 8; i++) {
					string name = worksheet.Cells[1, i].Value.ToString();
					if (i != 8) {
						start_query += "[" + name + "], ";
					} else {
						start_query += "[" + name + "]) values ('" + DateTime.Now.ToShortDateString() + "', " +
							ControllerManager.project_controller.getProjectId(selected_project.getProjectName()) + ", " +
							ControllerManager.project_controller.calculate_report_period(selected_project.getProjectStart().ToString()) +
							", ";
					}
				}

				for (int row = 2; row <= worksheet.Dimension.End.Row; row++) {
					string insert_query = start_query;
					for (int col = 1; col <= 8; col++) {
						if (col != 8) {
							insert_query += "'" + worksheet.Cells[row, col].Value.ToString() + "', ";
						} else {
							insert_query += "'" + worksheet.Cells[row, col].Value + "')";
						}
					}
					if (!ControllerManager.data_controller.executeQuery(insert_query)) {
						MessageBox.Show("Data could not be entered due to a data error.", "Error", MessageBoxButtons.OK,
							MessageBoxIcon.Error);
						return;
					}
				}

				MessageBox.Show("Data entered successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

			} else if (worksheet.Name.Equals("projectBaselines")) {
				string start_query = "insert into ";
				start_query += "dbo" + worksheet.Name + " (projectId, baselineDate, linkId, baseline) values (" +
					ControllerManager.project_controller.getProjectId(selected_project.getProjectName()) + ", " +
					"'" + DateTime.Now.ToShortDateString() + "', ";

				for (int row = 2; row <= worksheet.Dimension.End.Row; row++) {
					string insert_query = start_query;
					int metricId;
					int mpId;
					int linkId;
					linkId = ControllerManager.metrics_controller.getLinkId(worksheet.Cells[row, 1].Value.ToString(),
						worksheet.Cells[row, 2].Value.ToString(), out metricId, out mpId);

					int temp;
					if (!Int32.TryParse(worksheet.Cells[row, 3].Value.ToString(), out temp)) {
						MessageBox.Show("Data could not be entered due to a data error.", "Error", MessageBoxButtons.OK,
							MessageBoxIcon.Error);
						return;
					}
					insert_query += linkId + ", " + temp + ")";

					if (!ControllerManager.data_controller.executeQuery(insert_query)) {
						MessageBox.Show("Data could not be entered due to a data error.", "Error", MessageBoxButtons.OK,
							MessageBoxIcon.Error);
						return;
					}
				}

				MessageBox.Show("Data entered successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
			} else {
				string start_query = "insert into ";
				start_query += "dbo" + worksheet.Name + " (projectId, reportDate, linkId, actualResult) values (" +
					ControllerManager.project_controller.getProjectId(selected_project.getProjectName()) + ", " +
					"'" + DateTime.Now.ToShortDateString() + "', ";

				for (int row = 2; row <= worksheet.Dimension.End.Row; row++) {
					string insert_query = start_query;
					int metricId;
					int mpId;
					int linkId;
					linkId = ControllerManager.metrics_controller.getLinkId(worksheet.Cells[row, 1].Value.ToString(),
						worksheet.Cells[row, 2].Value.ToString(), out metricId, out mpId);

					int temp;
					if (!Int32.TryParse(worksheet.Cells[row, 3].Value.ToString(), out temp)) {
						MessageBox.Show("Data could not be entered due to a data error.", "Error", MessageBoxButtons.OK,
							MessageBoxIcon.Error);
						return;
					}
					insert_query += linkId + ", " + Int32.Parse(worksheet.Cells[row, 3].Value.ToString()) + ")";

					if (!ControllerManager.data_controller.executeQuery(insert_query)) {
						MessageBox.Show("Data could not be entered due to a data error.", "Error", MessageBoxButtons.OK,
							MessageBoxIcon.Error);
						return;
					}
				}

				MessageBox.Show("Data entered successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
			}
		}

		private bool validate_input_file(string path)
		{
			if (!Path.GetExtension(txtFilePath.Text).Equals(".xlsx")) {
				MessageBox.Show("Input file is not an Excel File (.xslx)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return false;
			}

			FileInfo file = new FileInfo(path);
			ExcelPackage excelPackage = new ExcelPackage(file);
			var workbook = excelPackage.Workbook;
			var worksheet = workbook.Worksheets[1];

			if (worksheet.Name.Equals("excelGhanttView")) {
				bool[] colHeadersValid = new bool[8];


				for (int i = 1; i <= 8; i++) {
					string name = worksheet.Cells[1, i].Value.ToString();
					switch (i) {
						case 1:
							if (name.Equals("Task Mode")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 2:
							if (name.Equals("Task Name")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 3:
							if (name.Equals("Duration")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 4:
							if (name.Equals("Start")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 5:
							if (name.Equals("Finish")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 6:
							if (name.Equals("Predecessors")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 7:
							if (name.Equals("Resource Names")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 8:
							if (name.Equals("Resource Group")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
					}

				}

				foreach (bool item in colHeadersValid) {
					if (!item) {
						MessageBox.Show("Invalid excelGhanttView excel file.\n" +
							"Column headers do not match template.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
						return false;
					}
				}
			} else if (worksheet.Name.Equals("projectBaselines")) {
				bool[] colHeadersValid = new bool[3];

				for (int i = 1; i <= 3; i++) {
					string name = worksheet.Cells[1, i].Value.ToString();

					switch (i) {
						case 1:
							if (name.Equals("actualMetric")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 2:
							if (name.Equals("parameter")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 3:
							if (name.Equals("baseline")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
					}
				}

				foreach (bool item in colHeadersValid) {
					if (!item) {
						MessageBox.Show("Invalid projectBaselines excel file.\n" +
							"Column headers do not match template.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
						return false;
					}
				}
			} else if (worksheet.Name.Equals("ProjectActualResults")) {
				bool[] colHeadersValid = new bool[3];

				for (int i = 1; i <= 3; i++) {
					string name = worksheet.Cells[1, i].Value.ToString();

					switch (i) {
						case 1:
							if (name.Equals("actualMetric")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 2:
							if (name.Equals("parameter")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
						case 3:
							if (name.Equals("actualResult")) {
								colHeadersValid[i - 1] = true;
								break;
							} else {
								colHeadersValid[i - 1] = false;
								break;
							}
					}
				}

				foreach (bool item in colHeadersValid) {
					if (!item) {
						MessageBox.Show("Invalid ProjectActualResults excel file.\n" +
							"Column headers do not match template.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
						return false;
					}
				}
			} else {
				MessageBox.Show("Invalid Excel file please ensure the file follow required format.", "Error", MessageBoxButtons.OK,
					MessageBoxIcon.Error);
				return false;
			}
			return true;
		}

		private void btnRefresh_Click(object sender, EventArgs e)
		{
			cbxReportSelector_SelectedIndexChanged(sender, e);
		}

		private void btnBuildGraphs_Click(object sender, EventArgs e)
		{
			ChartRefresh();
			chtChartDisplay.Visible = false;
			btnPrintGraph.Enabled = true;

			DataTable chart_results = new DataTable();
			DataTable chart_baselines = new DataTable();
			string li_selection = cbxLISelector.Text.ToString();

            chart_results = ControllerManager.chart_controller.getChartReports(this.selected_project.getProjectName(), li_selection);
            chart_baselines = ControllerManager.chart_controller.getChartBaselines(this.selected_project.getProjectName(), li_selection);

			int rows = 0;
			foreach (DataRow r in chart_results.Rows) {
				rows++;
			}

			//////////////////////////////////// Charts ////////////////////////////////////////////////////////////

			if (li_selection == "Tasks Complete") {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series2"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
				this.chtChartDisplay.Series["Series2"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "Planned";
				series2_name = "Completed";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;
				this.chtChartDisplay.Series["Series2"].Name = series2_name;

				for (int i = 0; i < rows; i++) {
					this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_baselines.Rows[i].ItemArray[1].ToString(), chart_baselines.Rows[i].ItemArray[5]);
				}

				for (int i = 0; i < rows; i++) {
					this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), chart_results.Rows[i].ItemArray[5]);
				}

				chtChartDisplay.Visible = true;
			}

			if (li_selection == "Requirements Coverage") { //////////////// lacks appropriate database entries (Requirements Coverage needs 2x parameters, and only has one) /////////////
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "Percentage";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;

				double percentage = 0;

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[4].ToString() == "verified") //// <---- does not exist in database; no "verified" or "traceable" parameters, only "none"
                    {
						string date = chart_results.Rows[i].ItemArray[1].ToString();
						int conversion_temp1 = (int)chart_results.Rows[i].ItemArray[5];
						double total = (double)conversion_temp1;

						for (int j = i + 1; j < rows; j++) {
							if (chart_results.Rows[j].ItemArray[1].ToString() == date) {
								int conversion_temp2 = (int)chart_results.Rows[j].ItemArray[5];
								double holder1 = (double)conversion_temp2;
								total += holder1;
							}
						}

						int conversion_temp3 = (int)chart_results.Rows[i].ItemArray[5];
						double holder2 = (double)conversion_temp3;

						percentage = (holder2 / total);

						this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), percentage);
					}
				}

				chtChartDisplay.Visible = true;
			}

			if (li_selection == "Staffing Profile") {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series2"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series3"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
				this.chtChartDisplay.Series["Series2"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
				this.chtChartDisplay.Series["Series3"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "Projected";
				series2_name = "Technical";
				series3_name = "Other";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;
				this.chtChartDisplay.Series["Series2"].Name = series2_name;
				this.chtChartDisplay.Series["Series3"].Name = series3_name;

				for (int i = 0; i < rows; i++) {
					this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_baselines.Rows[i].ItemArray[1].ToString(), chart_baselines.Rows[i].ItemArray[5]);
				}

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[4].ToString() == "technical") {
						this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), chart_results.Rows[i].ItemArray[5]);
					}
				}

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[4].ToString() == "other") {
						this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), chart_results.Rows[i].ItemArray[5]);
					}
				}

				chtChartDisplay.Visible = true;
			}

			if (li_selection == "Component Stability" || li_selection == "Software Lines of Code Count")  // find these charts in cbxCSDate_SelectIndexChanged
            {
				string query = "";
				DataSet ds = new DataSet();
				DataTable dt = new DataTable();
				csdates = new ArrayList();

				query = "select distinct reportDate from Q_ProjectReportedResults where indicatorName='" + li_selection + "'";
				ds = ControllerManager.data_controller.executeSelectQuery(query);

				if (ds != null) {
					dt = ds.Tables[0];

					foreach (DataRow row in dt.Rows) {
						csdates.Add(row.ItemArray[0].ToString());
					}

					if (csdates.Count != 0) {
						foreach (var r in csdates) {
							cbxCSDate.Items.Add(r);
						}
					}
				}

				MessageBox.Show("Please select a reporting period.");

				lblLISelector.Visible = false;
				cbxLISelector.Visible = false;
				lblCSDate.Visible = true;
				cbxCSDate.Visible = true;
			}

			if (li_selection == "Percentage of Defined Interfaces") {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "Percentage";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;

				double percentage = 0;

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[4].ToString() == "Defined") {
						string date = chart_results.Rows[i].ItemArray[1].ToString();
						int conversion_temp1 = (int)chart_results.Rows[i].ItemArray[5];
						double total = (double)conversion_temp1;

						for (int j = i + 1; j < rows; j++) {
							if (chart_results.Rows[j].ItemArray[1].ToString() == date) {
								int conversion_temp2 = (int)chart_results.Rows[j].ItemArray[5];
								double holder1 = (double)conversion_temp2;
								total += holder1;
							}
						}

						int conversion_temp3 = (int)chart_results.Rows[i].ItemArray[5];
						double holder2 = (double)conversion_temp3;

						percentage = (holder2 / total);

						this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), percentage);
					}
				}

				chtChartDisplay.Visible = true;
			}

			if (li_selection == "Requirements Churn")  //////////////// lacks appropriate database entries (Requirements Churn needs 2x parameters, and only has one) /////////////
            {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "Percentage";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;

				double percentage = 0;

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[4].ToString() == "other") //// <---- does not exist in database; no "other" or "none" parameters, only "changes"
                    {
						string date = chart_results.Rows[i].ItemArray[1].ToString();
						int conversion_temp1 = (int)chart_results.Rows[i].ItemArray[5];
						double total = (double)conversion_temp1;

						for (int j = i + 1; j < rows; j++) {
							if (chart_results.Rows[j].ItemArray[1].ToString() == date) {
								int conversion_temp2 = (int)chart_results.Rows[j].ItemArray[5];
								double holder1 = (double)conversion_temp2;
								total += holder1;
							}
						}

						int conversion_temp3 = (int)chart_results.Rows[i].ItemArray[5];
						double holder2 = (double)conversion_temp3;

						percentage = (holder2 / total);

						this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), percentage);
					}
				}

				chtChartDisplay.Visible = true;
			}

			if (li_selection == "Defect Profile") {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series2"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
				this.chtChartDisplay.Series["Series2"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "Desired";
				series2_name = "Actual";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;
				this.chtChartDisplay.Series["Series2"].Name = series2_name;

				for (int i = 0; i < rows; i++) {
					this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_baselines.Rows[i].ItemArray[1].ToString(), chart_baselines.Rows[i].ItemArray[5]);
					this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), chart_results.Rows[i].ItemArray[5]);
				}

				chtChartDisplay.Visible = true;
			}

			if (li_selection == "Software Design Coverage") //////////////// lacks appropriate database entries (SDC needs 2x parameters, and only has one) /////////////
            {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "Percentage";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;

				double percentage = 0;

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[4].ToString() == "traceable") //// <---- does not exist in database; no "traceable" or "verified" parameters, only "none"
                    {
						string date = chart_results.Rows[i].ItemArray[1].ToString();
						int conversion_temp1 = (int)chart_results.Rows[i].ItemArray[5];
						double total = (double)conversion_temp1;

						for (int j = i + 1; j < rows; j++) {
							if (chart_results.Rows[j].ItemArray[1].ToString() == date) {
								int conversion_temp2 = (int)chart_results.Rows[j].ItemArray[5];
								double holder1 = (double)conversion_temp2;
								total += holder1;
							}
						}

						int conversion_temp3 = (int)chart_results.Rows[i].ItemArray[5];
						double holder2 = (double)conversion_temp3;

						percentage = (holder2 / total);

						this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), percentage);
					}
				}

				chtChartDisplay.Visible = true;
			}

			if (li_selection == "Test Coverage") {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series2"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series3"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
				this.chtChartDisplay.Series["Series2"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
				this.chtChartDisplay.Series["Series3"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "White Box";
				series2_name = "Black Box";
				series3_name = "Total";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;
				this.chtChartDisplay.Series["Series2"].Name = series2_name;
				this.chtChartDisplay.Series["Series3"].Name = series3_name;

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[4].ToString() == "white box") {
						double percentage_white = 0;
						double percentage_black = 0;
						double total_coverage = 0;

						string date = chart_results.Rows[i].ItemArray[1].ToString();
						int conversion_temp1 = (int)chart_results.Rows[i].ItemArray[5];
						double total = (double)conversion_temp1;
						double black_box = 0;

						for (int j = i + 1; j < rows; j++) {
							if (chart_results.Rows[j].ItemArray[1].ToString() == date) {
								int conversion_temp2 = (int)chart_results.Rows[j].ItemArray[5];
								black_box = (double)conversion_temp2;
								total += black_box;
							}
						}

						int conversion_temp3 = (int)chart_results.Rows[i].ItemArray[5];
						double white_box = (double)conversion_temp3;

						percentage_white = (white_box / total);
						percentage_black = (black_box / total);
						total_coverage = percentage_black + percentage_white;

						this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), percentage_white);
						this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), percentage_black);
						this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), total_coverage);
					}
				}

				chtChartDisplay.Visible = true;
			}

			if (li_selection == "Execution Failure Rate") {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "Percentage";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;

				double percentage = 0;

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[4].ToString() == "failed") {
						string date = chart_results.Rows[i].ItemArray[1].ToString();
						int conversion_temp1 = (int)chart_results.Rows[i].ItemArray[5];
						double total = (double)conversion_temp1;

						for (int j = i + 1; j < rows; j++) {
							if (chart_results.Rows[j].ItemArray[1].ToString() == date) {
								int conversion_temp2 = (int)chart_results.Rows[j].ItemArray[5];
								double holder1 = (double)conversion_temp2;
								total += holder1;
							}
						}

						int conversion_temp3 = (int)chart_results.Rows[i].ItemArray[5];
						double holder2 = (double)conversion_temp3;

						percentage = (holder2 / total);

						this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), percentage);
					}
				}

				chtChartDisplay.Visible = true;
			}

			if (li_selection == "Productivity")  ////////////////////// incomplete - needs proposal ///////////////////////////////
            {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series2"].IsVisibleInLegend = true;
                this.chtChartDisplay.Series["Series3"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
				this.chtChartDisplay.Series["Series2"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                this.chtChartDisplay.Series["Series3"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "Planned";
				series2_name = "Productivity";
                series3_name = "Proposed";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;
				this.chtChartDisplay.Series["Series2"].Name = series2_name;
                this.chtChartDisplay.Series["Series3"].Name = series3_name;

				for (int i = 0; i < rows; i++) {
    				this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_baselines.Rows[i].ItemArray[1].ToString(), chart_baselines.Rows[i].ItemArray[5]);
                    this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), chart_results.Rows[i].ItemArray[5]);
                    this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), 10);
				}

				for (int i = 0; i < rows; i++) {
				}

				chtChartDisplay.Visible = true;
			}

			if (li_selection == "CM Churn") {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

				series1_name = "Percentage";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;

				double percentage = 0;

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[4].ToString() == "modified") {
						string date = chart_results.Rows[i].ItemArray[1].ToString();
						int conversion_temp1 = (int)chart_results.Rows[i].ItemArray[5];
						double total = (double)conversion_temp1;

						for (int j = i + 1; j < rows; j++) {
							if (chart_results.Rows[j].ItemArray[1].ToString() == date) {
								int conversion_temp2 = (int)chart_results.Rows[j].ItemArray[5];
								double holder1 = (double)conversion_temp2;
								total += holder1;
							}
						}

						int conversion_temp3 = (int)chart_results.Rows[i].ItemArray[5];
						double holder2 = (double)conversion_temp3;

						percentage = (holder2 / total);

						this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[1].ToString(), percentage);
					}
				}

				chtChartDisplay.Visible = true;
			}

			//////////////////////////////// End Charts //////////////////////////////////////////////////////////

			chart_results = null;
			chart_baselines = null;
		}

		private void ChartRefresh()
		{
			this.chtChartDisplay.Series[series1_name].Name = "Series1";
			this.chtChartDisplay.Series[series2_name].Name = "Series2";
			this.chtChartDisplay.Series[series3_name].Name = "Series3";
			this.chtChartDisplay.Series[series4_name].Name = "Series4";
			this.chtChartDisplay.Series[series5_name].Name = "Series5";
			this.chtChartDisplay.Series[series6_name].Name = "Series6";
			this.chtChartDisplay.Series[series7_name].Name = "Series7";
			this.chtChartDisplay.Series[series8_name].Name = "Series8";

			series1_name = "Series1";
			series2_name = "Series2";
			series3_name = "Series3";
			series4_name = "Series4";
			series5_name = "Series5";
			series6_name = "Series6";
			series7_name = "Series7";
			series8_name = "Series8";

			this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = false;
			this.chtChartDisplay.Series["Series2"].IsVisibleInLegend = false;
			this.chtChartDisplay.Series["Series3"].IsVisibleInLegend = false;
			this.chtChartDisplay.Series["Series4"].IsVisibleInLegend = false;
			this.chtChartDisplay.Series["Series5"].IsVisibleInLegend = false;
			this.chtChartDisplay.Series["Series6"].IsVisibleInLegend = false;
			this.chtChartDisplay.Series["Series7"].IsVisibleInLegend = false;
			this.chtChartDisplay.Series["Series8"].IsVisibleInLegend = false;

			foreach (var series in chtChartDisplay.Series) {
				series.Points.Clear();
			}

			chtChartDisplay.Visible = false;
		}

		private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
		{
			cbxReportSelector.Items.Clear();
			reports.Clear();

			if (cbxReportSelector.Text != null || cbxReportSelector.Text != "") {
				string query = "";
				DataSet ds2 = new DataSet();
				DataTable dt2 = new DataTable();

				ds2 = null;
				dt2 = null;

				query = "select distinct indicatorName from Q_ProjectReportedResults";
				ds2 = ControllerManager.data_controller.executeSelectQuery(query);

				if (ds2 != null) {
					dt2 = ds2.Tables[0];

					foreach (DataRow row in dt2.Rows) {
						reports.Add(row.ItemArray[0].ToString());
					}

					if (reports.Count != 0) {
						foreach (var r in reports) {
							cbxReportSelector.Items.Add(r);
						}
					}
				}
			}
		}

		private void cbxCIASelector_SelectedIndexChanged(object sender, EventArgs e)
		{
			lblCSDate.Visible = false;
			cbxCSDate.Visible = false;
			cbxCSDate.Items.Clear();

			lblLISelector.Visible = true;
			cbxLISelector.Visible = true;

			cbxLISelector.Items.Clear();
			cbxMeasureSelector.Items.Clear();

			DataSet ds = new DataSet();
			DataTable dt = new DataTable();

			// Get ciaId first
			int ciaId;
			string ciaid_query = "select ciaId from dboCIA where category='" +
				cbxCIASelector.SelectedItem.ToString() + "'";
			ds = ControllerManager.data_controller.executeSelectQuery(ciaid_query);
			dt = ds.Tables[0];
			ciaId = (int)dt.Rows[0].ItemArray[0];

			// get measure categories to populate dropdown
			string mCat_query = "select categoryName from dbomCategory where ciaId=" + ciaId;
			ds = ControllerManager.data_controller.executeSelectQuery(mCat_query);
			dt = ds.Tables[0];

			foreach (DataRow row in dt.Rows) {
				cbxMeasureSelector.Items.Add(row.ItemArray[0].ToString());
			}
		}

		private void cbxMeasureSelector_SelectedIndexChanged(object sender, EventArgs e)
		{
			lblCSDate.Visible = false;
			cbxCSDate.Visible = false;
			cbxCSDate.Items.Clear();

			lblLISelector.Visible = true;
			cbxLISelector.Visible = true;

			cbxLISelector.Items.Clear();

			DataSet ds = new DataSet();
			DataTable dt = new DataTable();

			// get the catId first
			int catId;
			string catId_query = "select catId from dbomCategory where categoryName='" +
				cbxMeasureSelector.SelectedItem.ToString() + "'";
			ds = ControllerManager.data_controller.executeSelectQuery(catId_query);
			dt = ds.Tables[0];
			catId = (int)dt.Rows[0].ItemArray[0];

			// get the Li's associated with it
			string li_query = "select indicatorName from dboLi where catId=" + catId;
			ds = ControllerManager.data_controller.executeSelectQuery(li_query);
			dt = ds.Tables[0];

			foreach (DataRow row in dt.Rows) {
				cbxLISelector.Items.Add(row.ItemArray[0].ToString());
			}
		}

		private void chbxBaseline_CheckedChanged(object sender, EventArgs e)
		{
			cbxReportSelector_SelectedIndexChanged(sender, e);
		}

		private void cbxCSDate_SelectedIndexChanged(object sender, EventArgs e)
		{
			string selected = cbxCSDate.SelectedItem.ToString();

			lblCSDate.Visible = false;
			cbxCSDate.Visible = false;
			cbxCSDate.Items.Clear();

			lblLISelector.Visible = true;
			cbxLISelector.Visible = true;

			ChartRefresh();

			DataTable chart_results = new DataTable();
			DataTable chart_baselines = new DataTable();
			string li_selection = cbxLISelector.Text.ToString();

            chart_results = ControllerManager.chart_controller.getChartReports(this.selected_project.getProjectName(), li_selection);
            chart_baselines = ControllerManager.chart_controller.getChartBaselines(this.selected_project.getProjectName(), li_selection);

			int rows = 0;
			foreach (DataRow r in chart_results.Rows) {
				rows++;
			}

			if (li_selection == "Component Stability") /////////////////////////  needs refactoring ////////////////////
            {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series2"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series3"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series4"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series5"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series6"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series7"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series8"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
				this.chtChartDisplay.Series["Series2"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
				this.chtChartDisplay.Series["Series3"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
				this.chtChartDisplay.Series["Series4"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
				this.chtChartDisplay.Series["Series5"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
				this.chtChartDisplay.Series["Series6"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
				this.chtChartDisplay.Series["Series7"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
				this.chtChartDisplay.Series["Series8"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;

				series1_name = "reqs inspection";
				series2_name = "design inspection";
				series3_name = "code inspection";
				series4_name = "unit test inspection";
				series5_name = "informal integration test";
				series6_name = "integration test";
				series7_name = "component qual";
				series8_name = "release test";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;
				this.chtChartDisplay.Series["Series2"].Name = series2_name;
				this.chtChartDisplay.Series["Series3"].Name = series3_name;
				this.chtChartDisplay.Series["Series4"].Name = series4_name;
				this.chtChartDisplay.Series["Series5"].Name = series5_name;
				this.chtChartDisplay.Series["Series6"].Name = series6_name;
				this.chtChartDisplay.Series["Series7"].Name = series7_name;
				this.chtChartDisplay.Series["Series8"].Name = series8_name;

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[3].ToString() == "Configuration Manager") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}
					if (chart_results.Rows[i].ItemArray[3].ToString() == "Record Set") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}
					if (chart_results.Rows[i].ItemArray[3].ToString() == "Pedigree") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}
					if (chart_results.Rows[i].ItemArray[3].ToString() == "Explorer") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}
					if (chart_results.Rows[i].ItemArray[3].ToString() == "Data Filter") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}
					if (chart_results.Rows[i].ItemArray[3].ToString() == "Data Notification") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}
					if (chart_results.Rows[i].ItemArray[3].ToString() == "Admin User Settings Manager") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}
					if (chart_results.Rows[i].ItemArray[3].ToString() == "Framework") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}
					if (chart_results.Rows[i].ItemArray[3].ToString() == "Session Manager") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}
					if (chart_results.Rows[i].ItemArray[3].ToString() == "View Manager") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}
					if (chart_results.Rows[i].ItemArray[3].ToString() == "View Selector") {
						if (chart_results.Rows[i].ItemArray[4].ToString() == "reqs inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series1_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "design inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series2_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "code inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series3_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "unit test inspection" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series4_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "informal integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series5_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "integration test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series6_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "component qual" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series7_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
						if (chart_results.Rows[i].ItemArray[4].ToString() == "release test" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
							this.chtChartDisplay.Series[series8_name].Points.AddXY(chart_results.Rows[i].ItemArray[3].ToString(), (int)chart_results.Rows[i].ItemArray[5]);
						}
					}

				}

				this.chtChartDisplay.Visible = true;
			}

			if (li_selection == "Software Lines of Code Count")  //////  incomplete - clarification required to output appropriate data ////////////////////
            {
				this.chtChartDisplay.Series["Series1"].IsVisibleInLegend = true;
				this.chtChartDisplay.Series["Series2"].IsVisibleInLegend = true;

				this.chtChartDisplay.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
				this.chtChartDisplay.Series["Series2"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;

				series1_name = "Estimated";
				series2_name = "Current";

				this.chtChartDisplay.Series["Series1"].Name = series1_name;
				this.chtChartDisplay.Series["Series2"].Name = series2_name;

				int total = 0;

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[1].ToString() == selected) {
						total += (int)chart_results.Rows[i].ItemArray[5];
					}
				}

				for (int i = 0; i < rows; i++) {
					if (chart_results.Rows[i].ItemArray[4].ToString() == "CM control" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
						this.chtChartDisplay.Series[series1_name].Points.AddXY("CM vs Total SLOC", (int)chart_results.Rows[i].ItemArray[5]);
					}
					if (chart_results.Rows[i].ItemArray[4].ToString() == "new" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
						this.chtChartDisplay.Series[series1_name].Points.AddXY("New vs Estimated", (int)chart_results.Rows[i].ItemArray[5]);
					}
					if (chart_results.Rows[i].ItemArray[4].ToString() == "new" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
						this.chtChartDisplay.Series[series1_name].Points.AddXY("New vs Estimated", (int)chart_results.Rows[i].ItemArray[5]);
					}
					if (chart_results.Rows[i].ItemArray[4].ToString() == "new" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
						this.chtChartDisplay.Series[series1_name].Points.AddXY("New vs Estimated", (int)chart_results.Rows[i].ItemArray[5]);
					}
					if (chart_results.Rows[i].ItemArray[4].ToString() == "new" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
						this.chtChartDisplay.Series[series1_name].Points.AddXY("New vs Estimated", (int)chart_results.Rows[i].ItemArray[5]);
					}
					if (chart_results.Rows[i].ItemArray[4].ToString() == "new" && chart_results.Rows[i].ItemArray[1].ToString() == selected) {
						this.chtChartDisplay.Series[series1_name].Points.AddXY("New vs Estimated", (int)chart_results.Rows[i].ItemArray[5]);
					}

				}


				chtChartDisplay.Visible = true;
			}
		}

		private void rbtnPM_CheckedChanged(object sender, EventArgs e)
		{
			btnUpdate.Enabled = true;
		}

		private void rbtnUser_CheckedChanged(object sender, EventArgs e)
		{
			btnUpdate.Enabled = true;
		}

		private void txtFirstName_TextChanged(object sender, EventArgs e)
		{
			btnUpdate.Enabled = true;
		}

		private void txtLastName_TextChanged(object sender, EventArgs e)
		{
			btnUpdate.Enabled = true;
		}

		private void txtEmail_TextChanged(object sender, EventArgs e)
		{
			btnUpdate.Enabled = true;
		}

		private void txtPassword_TextChanged(object sender, EventArgs e)
		{
			btnUpdate.Enabled = true;
		}

		private void btnPrintGraph_Click(object sender, EventArgs e)
		{
			printGraphDocument.Print();
		}

		private void printGraphDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
		{
			Bitmap bm = new Bitmap(this.chtChartDisplay.Width, this.chtChartDisplay.Height);
			chtChartDisplay.DrawToBitmap(bm, new Rectangle(0, 0, this.chtChartDisplay.Width, this.chtChartDisplay.Height));
			e.Graphics.DrawImage(bm, 0, 0);
		}

		private void btnPrintReport_Click(object sender, EventArgs e)
		{
			printReportDocument.Print();
		}

		private void printReportDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
		{
			Bitmap bm = new Bitmap(this.gvReports.Width, this.gvReports.Height);
			gvReports.DrawToBitmap(bm, new Rectangle(0, 0, this.gvReports.Width, this.gvReports.Height));
			e.Graphics.DrawImage(bm, 0, 0);
		}

	}
}